#include<calculator.h>

calculator::calculator()
{

}
calculator::~calculator()
{

}
double calculator::add(double a, double b)
{
	if (m_handler) {
		m_handler(a + b);
	}
	return a + b;
};
double calculator::sub(double a, double b)
{
	if (m_handler) {
		m_handler(a - b);
	}
	return a - b;
};
double calculator::mult(double a, double b)
{
	if (m_handler) {
		m_handler(a * b);
	}
	return a * b;
};
double calculator::div(double a, double b)
{
	if ((int)b == 0) {
		if (m_handler) {
			m_handler(0XFFFFFFFF);
		}
		return 0XFFFFFFFF;
	}
	if (m_handler) {
		m_handler(a / b);
	}
	return a / b;
};
void calculator::setName(std::string name)
{
	this->name = name;
}
std::string calculator::getName()
{
	return this->name;
}

void calculator::registerCallBack(std::function<void(int)>& handler)
{
	m_handler = handler;
}
